`include "defines.svh"
// `define FUNCFAST
module MMU(
    input logic [31:0]VirtualAddr,  //虚拟地址
    
    output logic [31:0]PhysicalAddr,   //物理地址
    output logic isCache          //判定是否是属于Uncache的地址
);

    always_comb begin
        if(VirtualAddr < 32'hC000_0000 && VirtualAddr > 32'h9FFF_FFFF) begin
            PhysicalAddr = VirtualAddr - 32'hA000_0000;    
        end
        else if(VirtualAddr < 32'hA000_0000 && VirtualAddr > 32'h7FFF_FFFF) begin
            PhysicalAddr = VirtualAddr - 32'h8000_0000;
            
        end
        else begin
            PhysicalAddr = VirtualAddr;    
        end
    end
`ifndef FUNCFAST    
    always_comb begin
        if(VirtualAddr < 32'hC000_0000 && VirtualAddr > 32'h9FFF_FFFF) begin
            isCache = '0;
        end
        else begin
            isCache = '1;
        end
    end
`endif
`ifdef FUNCFAST
    always_comb begin
        if (VirtualAddr[31:16] == 16'hbfaf) 
            isCache = '0;
        else
            isCache = '1;
    end
`endif

endmodule
